package org.fioma.ui;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class ReadsGeneration {

	public static void main(String[] args) {
		long seqSize = Integer.parseInt(args[0]);
		long fold = Integer.parseInt(args[1]);
		long readSize = Integer.parseInt(args[2]);

		char[] letters = { 'A', 'T', 'C', 'G' };

		char[] seq = new char[(int) seqSize];

		for (int i = 0; i < seqSize; i++) {
			seq[i] = letters[(int) (Math.random() * 4)];
		}

		BufferedWriter bw = null;
		try {
			bw = new BufferedWriter(new FileWriter(args[3], false));

			long start;
			long qttyReads = (seqSize * fold) / readSize;

			for (long i = 0; i < qttyReads; i++) {
				start = (long) (Math.random() * seqSize);
				bw.write('@');
				bw.newLine();
				for (int j = (int) start; j < seqSize && j < start + readSize; j++) {
					bw.write(seq[j]);
				}
				bw.newLine();
				bw.write('+');
				bw.newLine();
				bw.write('#');
				bw.newLine();

			}
			bw.flush();

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
